/*
Copyright (C) Ariff Ehsan, Abdul Hadi Fikri

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
*/

/*  Author : Ariff Ehsan
 *           Abdul Hadi Fikri
 *  Date   : June 22, 2009
 */


#ifndef __SERIAL0_H__
#define __SERIAL0_H__

#include <types/anos_error.h>


#ifndef SERIAL0_BAUD
#define SERIAL0_BAUD 9600
#endif

#define DRIVER_USART0_BAUD SERIAL0_BAUD


/**
 *  PORT SPECIFIC HEADER FILE
 */


#if defined (__AVR_ATmega16__)
#include <serial0/ports/atmega16/atmega16_usart0.h>

#elif defined (__AVR_ATmega644P__)
#include <serial0/ports/atmega644p/atmega644p_usart0.h>

#else
#error the library is not supported for configured microcontroller

#endif


/**
 *  GLOBAL PROTOTYPE FUNCTION
 */

	void SERIAL0_init(void);
	void SERIAL0_reg(void (*bytedone)(void), 
					 void (*streamdone)(error_t), 
				 	 void (*receive)(uint8_t));
					 
	error_t SERIAL0_sendByte(uint8_t);
	error_t SERIAL0_sendStream(uint8_t *, uint8_t);


#endif // __SERIAL0_H__
